'use strict';

const Controller = require('../core/base_controller');

class ShopController extends Controller {
  async getShopList() {
    const { ctx, app } = this;

    try {
      const res = await ctx.service.shop.getShopList();
      this.success(res)
    } catch (err) {
      this.error(err.message)
    }
  }
  async getShopDetail() {
    const { ctx, app } = this;

    try {
      const res = await ctx.service.shop.getShopDetail();
      this.success(res)
    } catch (err) {
      this.error(err.message)
    }
  }
  async addToCart() {
    const { ctx, app } = this;

    try {
      const res = await ctx.service.shop.addToCart();
      this.success(res)
    } catch (err) {
      this.error(err.message)
    }
  }
  async getCartList() {
    const { ctx, app } = this;

    try {
      const res = await ctx.service.shop.getCartList();
      this.success(res)
    } catch (err) {
      this.error(err.message)
    }
  }
  async setCartCount() {
    const { ctx, app } = this;
    try {
      const res = await ctx.service.shop.setCartCount();
      this.success(res)
    } catch (err) {
      this.error(err.message)
    }
  }
  async delCartById() {
    const { ctx, app } = this;
    try {
      const res = await ctx.service.shop.delCartById();
      this.success(res)
    } catch (err) {
      this.error(err.message)
    }
  }

}

module.exports = ShopController;
// const mock = require('mockjs')
// const { list } = mock.mock({
//   "list|100": [{
//     title: "@ctitle(5,10)",
//     detail: "@ctitle(50,100)",
//     "price|1-1000": 1,
//     "count|1-1000": 1,
//     "sales|1-1000": 1,
//     image: "@image(100x100,@color)"
//   }]
// })
// list.forEach(item => {
//   app.mysql.insert('shops', { ...item })
// })
// ctx.body = '123'